﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Research.Kinect.Nui;

namespace KinectUserManager
{
    
    [TestClass]
    public static class TrakedSkeletonManager
    {
        public static SkeletonData [] TrakedSkelletons { get; private set;}
        


        [TestMethod]
        public static void OrderPlayerSkeletons(List<SkeletonData> skells, int firstPlayerID)
        {
                        
            TrakedSkelletons = new SkeletonData[skells.Count];
            if (skells.Count>1 && firstPlayerID > -1)
            {
                foreach (SkeletonData data in skells)
                {
                    if (firstPlayerID == data.TrackingID)
                    {
                        TrakedSkelletons[0] = data;
                    }
                    //esto es por si havia dos usuarios y ninguno de los dos es el que havia previamente
                    else
                    {
                        if (TrakedSkelletons[1] != null)
                        {
                            TrakedSkelletons[0] = TrakedSkelletons[1];
                            TrakedSkelletons[1] = data;
                        }
                        else
                        {
                            TrakedSkelletons[1] = data;
                        }
                    }
                }
                
            }
            else if (skells.Count > 0)
            {
                TrakedSkelletons = skells.ToArray();

            }
            else
            {
                TrakedSkelletons = new SkeletonData[0];
            }
            
        }

    }
 

}
